//package com.plian.system.service.hr.employment.impl;
//
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.entity.hr.employment.AdmissionResultRecordEntity;
//import com.plian.system.entity.hr.employment.AdmissionResultRecordInfoEntity;
//import com.plian.system.mapper.hr.employment.AdmissionResultRecordMapper;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.service.hr.employment.IAdmissionResultRecordInfoService;
//import com.plian.system.service.hr.employment.IAdmissionResultRecordService;
//import com.plian.system.vo.hr.employment.AdmissionResultRecordInfoVO;
//import com.plian.system.vo.hr.employment.AdmissionResultRecordVO;
//import com.plian.system.wrapper.hr.employment.AdmissionResultRecordInfoWrapper;
//import com.plian.system.wrapper.hr.employment.AdmissionResultRecordWrapper;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//import java.util.Optional;
//
//import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;
//
///**
// * 录取结果备案 服务实现类
// *
// * @author gangan
// * @since 2023-05-23
// */
//@Service
//@AllArgsConstructor
//public class AdmissionResultRecordServiceImpl extends BaseServiceImpl<AdmissionResultRecordMapper, AdmissionResultRecordEntity> implements IAdmissionResultRecordService {
//
//    private AdmissionResultRecordWrapper admissionResultRecordWrapper;
//
//    private IAdmissionResultRecordInfoService admissionResultRecordInfoService;
//
//    private AdmissionResultRecordInfoWrapper admissionResultRecordInfoWrapper;
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean saveOrUpdate(AdmissionResultRecordEntity entity) {
//        if (entity.getId() == null) {
//            entity.setFormType(String.valueOf(FormTypeConstant.HR_ADMISSION_RESULT_RECORD));
//            entity.setStatus(UNREVIEWED);
//        }
//        return super.saveOrUpdate(entity);
//    }
//
//    @Override
//    public AdmissionResultRecordVO getDetail(AdmissionResultRecordEntity admissionResultRecord) {
//        AdmissionResultRecordVO admissionResultRecordVO = admissionResultRecordWrapper.entityToVO(admissionResultRecord);
//        List<AdmissionResultRecordInfoEntity> childList = admissionResultRecordInfoService.list(Wrappers.<AdmissionResultRecordInfoEntity>lambdaQuery()
//                .eq(AdmissionResultRecordInfoEntity::getBaseResultRecordId, admissionResultRecord.getId()));
//        admissionResultRecordVO.setChildList(admissionResultRecordInfoWrapper.entityToVO(childList));
//        return admissionResultRecordVO;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean submit(AdmissionResultRecordVO admissionResultRecordVO) {
//        AdmissionResultRecordEntity entity = admissionResultRecordWrapper.voToEntity(admissionResultRecordVO);
//        boolean result = saveOrUpdate(entity);
//        List<AdmissionResultRecordInfoVO> childList = admissionResultRecordVO.getChildList();
//        if (CollectionUtil.isNotEmpty(childList)) {
//            for (AdmissionResultRecordInfoVO child : childList) {
//                if (child.getId() != null && Optional.ofNullable(child.getIsDeleted()).isPresent() && child.getIsDeleted().intValue() == 1) {
//                    admissionResultRecordInfoService.removeById(child.getId());
//                } else {
//                    child.setBaseResultRecordId(entity.getId());
//                    admissionResultRecordInfoService.saveOrUpdate(child);
//                }
//            }
//        }
//        return result;
//    }
//
//    @Override
//    @Transactional(rollbackFor = RuntimeException.class)
//    public boolean deleteLogic(List<Long> ids) {
//        boolean result = super.deleteLogic(ids);
//        if (result) {
//            admissionResultRecordInfoService.deleteLogicByParentId(ids);
//        }
//        return result;
//    }
//
//}
